import request from '@/utils/request'
const url = process.env.VUE_APP_USER_API || 'usr'

export default {
  // 4.16.1. 项目列表
  projectList(queryData) {
    return request({
      url: `${url}/api/v1/project/list`,
      method: 'get',
      params: queryData
    })
  },
  // 4.16.2. 新建项目
  projectAdd(paramsData) {
    return request({
      url: `${url}/api/v1/project/add`,
      method: 'post',
      data: paramsData
    })
  },
  // 4.16.3. 修改项目
  projectUpdate(projectId, paramsData) {
    return request({
      url: `${url}/api/v1/project/update/${projectId}`,
      method: 'put',
      data: paramsData
    })
  },
  // 4.16.4. 删除项目
  projectDelete(projectId) {
    return request({
      url: `${url}/api/v1/project/delete/${projectId}`,
      method: 'delete'
    })
  },

  // 4.16.5. 修改项目底图
  updateSketch(project_id, data) {
    return request({
      url: `${url}/api/v1/project/update/sketch/${project_id}`,
      method: 'post',
      data
    })
  },

  // 4.16.6.项目详情
  projectDetail(project_id) {
    return request({
      url: `${url}/api/v1/project/detail/${project_id}`,
      method: 'get'
    })
  },

  /* 分支模块 */
  // 4.5.1、查看分支列表
  branchList(queryData) {
    return request({
      url: `${url}/api/v1/branch/list`,
      method: 'get',
      params: queryData
    })
  },

  // 4.5.2、新增分支
  branchAdd(paramsData, tenantId) {
    return request({
      url: `${url}/api/v1/branch/add`,
      method: 'post',
      params: { tenant_id: tenantId },
      data: { data: paramsData }
    })
  },

  // 4.5.3、修改分支
  branchUpdate(branchId, paramsData) {
    return request({
      url: `${url}/api/v1/branch/update/${branchId}`,
      method: 'put',
      data: { data: paramsData }
    })
  },

  // 4.5.4、删除分支
  branchDelete(branchId) {
    return request({
      url: `${url}/api/v1/branch/delete/${branchId}`,
      method: 'delete'
    })
  },

  // 4.18.1. 分支总数
  branchTotal(projectId) {
    return request({
      url: `${url}/api/v1/branch/total`,
      method: 'get',
      params: projectId
    })
  }

}
